{% extends 'oscar/dashboard/layout.html' %}
{% load currency_filters %}
{% load i18n %}
{% load django_tables2 %}

{% block body_class %}{{ block.super }} orders{% endblock %}

{% block title %}
    {% trans "Order statistics" %} | {{ block.super }}
{% endblock %}

{% block breadcrumbs %}
    <ul class="breadcrumb">
        <li>
            <a href="{% url 'dashboard:index' %}">{% trans "Dashboard" %}</a>
        </li>
        <li>
            <a href="{% url 'dashboard:order-list' %}">{% trans "Orders" %}</a>
        </li>
        <li class="active">{% trans "Statistics" %}</li>
    </ul>
{% endblock %}

{% block headertext %}{{ title }}{% endblock %}

{% block dashboard_content %}
    <div class="table-header">
        <h3><i class="icon-filter icon-large"></i> {% trans "Filter" %}</h3>
    </div>
    <div class="well">
        <form method="get" action="{% url 'dashboard:order-stats' %}" class="form-inline">
            {% include "oscar/dashboard/partials/form_fields_inline.html" with form=form %}
            <button type="submit" class="btn btn-primary" data-loading-text="{% trans 'Filtering...' %}">{% trans "Filter result" %}</button>
            <a href="{% url 'dashboard:order-stats' %}" class="btn btn-default">{% trans "Reset" %}</a>
        </form>
    </div>

    <table class="table table-striped table-bordered table-hover">
        <caption><i class="icon-shopping-cart icon-large"></i>{% trans "Summary" %}</caption>
        <tr>
            <th>{% trans "Total orders" %}</th>
            <td>{{ total_orders }}</td>
        </tr>
        <tr>
            <th>{% trans "Total lines" %}</th>
            <td>{{ total_lines }}</td>
        </tr>
        <tr>
            <th>{% trans "Total revenue" %}</th>
            <td>{{ total_revenue|currency }}</td>
        </tr>
    </table>

    {% if order_status_breakdown %}
        <table class="table table-striped table-bordered table-hover">
            <caption><i class="icon-shopping-cart icon-large"></i>{% trans "Order status breakdown" %}</caption>
            <tr>
                <th>{% trans "Status" %}</th>
                <th>{% trans "Frequency" %}</th>
            </tr>
            {% for dict in order_status_breakdown %}
                <tr>
                    <td><a href="{% url 'dashboard:order-list' %}{% querystring 'status'=dict.status %}">{{ dict.status }}</a></td>
                    <td>{{ dict.freq }}</td>
                </tr>
            {% endfor %}
        </table>
    {% endif %}

{% endblock dashboard_content %}
